/* Add an image slider to #emotion-header div instead of existing picture */ /* by T. Groß, M. Bertling v 2.0 */ if (typeof imagepage === 'undefined' || imagepage === null) { var imagepage = "/images"; //hier den Pfad eingeben für die Bilder } var slidercontainer = "#sliderwrapper" // Hier die Ziel ID oder #emotion-header var showCaption = 1; var sliderConfig = { effect: 'fade', animSpeed: 500, pauseTime: 5000, directionNav: false, slices: 1, controlNav: false, controlNavThumbs: false }; var externalLinkTarget = '_blank'; var debug = 0; /* * * * * * / END OF SLIDER CONFIG * * * * */ /* * * * * * DO NOT CHANGE BELOW HERE * * * * */ var j = jQuery.noConflict(); (function($) { $(document).ready(function() { $('#sliderwrapper a').remove(); $('#sliderwrapper').removeAttr('style'); function teststring (re, str) { if (re.test(str)) { return true; } else { return false; } } function makeCaption (str) { var output; // remove linebreaks and leading spaces from caption if (str) { output = str.replace(/^(\s+)|(\r\n|\n|\r)/mgi, ""); } // check if caption should be blank if (teststring(/%%blank%%/i, output)) { output = ""; } return output; } function removeURLParameter(url, parameter) { //prefer to use l.search if you have a location/link object var urlparts = url.split('?'); if (urlparts.length>=2) { var prefix = encodeURIComponent(parameter)+'='; var pars = urlparts[1].split(/[&;]/g); //reverse iteration as may be destructive for (var i = pars.length; i-- > 0;) { //idiom for string.startsWith if (pars[i].lastIndexOf(prefix, 0) !== -1) { pars.splice(i, 1); } } url = urlparts[0] + (pars.length > 0? '?' + pars.join('&'): ""); return url; } else { return url; } } $.get(imagepage, function(data) { $.each($(data).find('.j-downloadDocument'), function() { // get image url and path var image = $('a.cc-m-download-link', this).attr('href'); if (debug==1) { console.log("image: " + image);} var reg = /.+?\:\/\/.+?(\/.+?)(?:#|\?|$)/; //var imagepath = reg.exec( image )[1]; var imagepath = removeURLParameter(image, 't'); if (debug==1) { console.log("imagepath: " + imagepath);} var imgTitleString; var linkString; // get link var link = $('.cc-m-download-title', this).text(); // get caption var caption = $('.cc-m-download-description', this).text(); if (link === '') { // no link given (no tag) if (showCaption == 1) { // split caption string from html. //caption = makeCaption(caption.split(/
/i)[0]); imgTitleString = ' title="' + caption + '" '; } else { imgTitleString = ''; } // create slide html $(slidercontainer).append(''); } else { // link in tag is given if (showCaption == 1) { // split caption string from html. //caption = makeCaption(caption.split(/
/i)[1]); imgTitleString = ' title="' + caption + '" '; } else { imgTitleString = ''; } // create '; if (debug==1) { console.log ('external link found: ' + linkString);} } else if (teststring(/^[^\/]/i, link)) { // put leading slash if it's not there linkString = ''; if (debug==1) { console.log ('added / to link: ' + linkString);} } else { // keep link as it is linkString = ''; if (debug==1) { console.log ('keep link as it is: ' + linkString);} } // create slide html $(slidercontainer).append(linkString + '<\/a>'); }; if (debug == 1) { console.log('CAPTION :' + caption); console.log('IMAGE: ' + image + ' ---> ' + imagepath); console.log('LINK: ' + linkString); } } ); // End of Each // activate slider on element $(slidercontainer).nivoSlider(sliderConfig); } ); // endof get } ); // end of document ready } )(j); // end of function